<?php

namespace addons\xapply;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Xapply extends Addons
{
    protected $menu = [
        [
            'name'    => 'xapply',
            'title'   => 'Xapply管理',
            'icon'    => 'fa fa-th-large',
            'ismenu'  => 1,
            'weigh'   => 100,
            'remark'  => '用于连接 XApply App',
            'sublist' => [
                [
                    'name'    => 'xapply/app',
                    'title'   => '应用管理',
                    'icon'    => 'fa fa-android',
                    'ismenu'  => 1,
                    'weigh'   => 3,
                    'sublist' => [
                        ['name' => 'xapply/app/index', 'title' => '查看'],
                        ['name' => 'xapply/app/add', 'title' => '添加'],
                        ['name' => 'xapply/app/edit', 'title' => '编辑'],
                        ['name' => 'xapply/app/del', 'title' => '删除'],
                        ['name' => 'xapply/app/multi', 'title' => '批量更新'],
                    ]
                ],
                [
                    'name'    => 'xapply/category',
                    'title'   => '分组管理',
                    'icon'    => 'fa fa-tags',
                    'ismenu'  => 1,
                    'weigh'   => 3,
                    'sublist' => [
                        ['name' => 'xapply/category/index', 'title' => '查看'],
                        ['name' => 'xapply/category/add', 'title' => '添加'],
                        ['name' => 'xapply/category/edit', 'title' => '编辑'],
                        ['name' => 'xapply/category/del', 'title' => '删除'],
                        ['name' => 'xapply/category/multi', 'title' => '批量更新'],
                    ]
                ]
            ]
        ]
    ];

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        Menu::create($this->menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("xapply");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("xapply");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("xapply");
        return true;
    }

}
